<div class="primary">
	<div id="shopping_cart-2" class="widget widget_shopping_cart">
		<h3>Cart</h3>
		<ul class="product_list_widget cart_list ">
		<?php
		if(Yii::app()->session['listcart'] != null){
			$total = 0;
			foreach(Yii::app()->session['listcart'] as $key=>$value){
				$product = Products::model()->findByPk($value['product_id']);
				if(!empty($product)) $total += $product->price * $value['quantity'];
				
				$path = "upload_files/products";
						
				$folder_dir = Yii::getPathOfAlias('webroot')."/wwwroot/{$path}/thumb_{$product->image}";
				if (!is_file($folder_dir)) {
					$src = "/uploads/no-image.png";
				} else {
					$src = "/wwwroot/{$path}/thumb_{$product->image}";
				}
		?>
			<li><a href="<?php echo Yii::app()->createUrl('/products/checkOut', array('pid' => $key));?>" title="<?php echo isset($product->name) ? $product->name : ""?>">
				<img width="119" height="200" src="<?php echo $src?>" class="attachment-shop_thumbnail wp-post-image" alt="<?php echo isset($product->style) ? $product->style : ""?>" />
				<?php echo isset($product->name) ? $product->name : ""?>
				</a> 
				<p class="from">Quantity: </span><span class="amount"><?php echo $value['quantity'];?></p>
				<p class="from">From: </span><span class="amount">&#36;<?php echo isset($product->price) ? $product->price : 0?></p>
				<p class="from">Offer: </span><span class="amount">&#36;<?php echo $product->price * $value['quantity'];?></p>
			</li>
		<?php
			}
		}else{
			echo '<li class="empty">No products in the cart.</li>';
		}
		?>
		</ul>
		<!--<ul class="cart_list product_list_widget ">
			<li class="empty">No products in the cart.</li>
		</ul>-->
	</div>	
	<div id="featured-products-2" class="widget widget_featured_products">
		<h3>Featured Products</h3>
		<ul class="product_list_widget">
			<?php 
				if (!empty($model)) :
					foreach ($model as $key=>$item):
					
						$path = "upload_files/products";
						
						$folder_dir = Yii::getPathOfAlias('webroot')."/wwwroot/{$path}/thumb_{$item->image}";
						if (!is_file($folder_dir)) {
							$src = "/uploads/no-image.png";
						} else {
							$src = "/wwwroot/{$path}/thumb_{$item->image}";
						}
			?>
			<li><a href="<?php echo Yii::app()->createUrl('/products/public/index', array('alias' => $item->alias))?>" title="<?php echo isset($item->name) ? $item->name : ""?>">
				<img width="119" height="200" src="<?php echo $src?>" class="attachment-shop_thumbnail wp-post-image" alt="<?php echo isset($model->style) ? $model->style : ""?>" />
				<?php echo isset($item->name) ? $item->name : ""?>
				</a> 
				<span class="from">From: </span><span class="amount">&#36;<?php echo isset($item->price) ? $item->price : 0?></span>
			</li>
			
			<?php 
					endforeach;
				endif;
			?>
		</ul>
	</div>
</div>